<?php
/***************************************************************************
 * 
 * Copyright (c) 2010 , Inc. All Rights Reserved
 * $Id$:TestURL.php,2010/05/25 16:26:33 
 * 
 **************************************************************************/
 
 
 
/**
 * @file TestURL.php
 * @author huqingping(huqingping@)
 * @date 2010/05/25 16:26:33
 * @version 1.0 
 * @brief 
 *  
 **/

final class TestURL extends TestCase
{
	function testOK()
	{
		$ret = $this->fetch('/HapN/sub/testUrl',array());
		$this->assertTrue(strncmp($ret->status,'200',3) === 0);
		$ret = $this->fetch('/HapN/testInput',array());
		$this->assertTrue(strncmp($ret->status,'200',3) === 0);
		$ret = $this->fetch('/HapN',array());
		$this->assertTrue(strncmp($ret->status,'200',3) === 0);
	}

	function testExtendArgs()
	{
		$encid = 'aaaaaaaaaaaa3aaaaaaaaaa1';
		$ret = $this->fetch('/extend/1/arg',array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals('e_arg_1',$json['data']['v']);

		$ret = $this->fetch("/extend/1/2/$encid/arg",array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals("e_arg_1_2_$encid",$json['data']['v']);

		$ret = $this->fetch("/extend/3/2/$encid/arg/f/4",array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals("e_arg_f_3_2_$encid"."_4",$json['data']['v']);
	}

	function testExtend()
	{
		$ret = $this->fetch('/extend/',array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals('hapn.ok',$json['err']);
		$this->assertEquals('e_',$json['data']['v']);

		$ret = $this->fetch('/extend/1',array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals('hapn.ok',$json['err']);
		$this->assertEquals('e_1',$json['data']['v']);

		$ret = $this->fetch('/extend/f2',array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals('hapn.ok',$json['err']);
		$this->assertEquals('e_f2',$json['data']['v']);

		$ret = $this->fetch('/extend/sub',array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals('hapn.ok',$json['err']);
		$this->assertEquals('e_sub_',$json['data']['v']);

		$ret = $this->fetch('/extend/sub/f1',array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals('hapn.ok',$json['err']);
		$this->assertEquals('e_sub_f1',$json['data']['v']);

		$ret = $this->fetch('/extend/sub/f3',array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals('hapn.ok',$json['err']);
		$this->assertEquals('e_sub_f3',$json['data']['v']);

	}

	function testNotfound()
	{
		$ret = $this->fetch('/notfound_mod/sub',array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals('hapn.u_notfound',$json['err']);

		$ret = $this->fetch('/notfound',array('get'=>array('_of'=>'json')));
		$json = $ret->json();
		$this->assertEquals('hapn.ok',$json['err']);
		
		$ret = $this->fetch('/HapN/sub/testUrl/',array());
		$this->assertTrue(strncmp($ret->status,'200',3) === 0);

		$ret = $this->fetch('/HapN/testInput/',array());
		$this->assertTrue(strncmp($ret->status,'200',3) === 0);
	}
	
}





/* vim: set ts=4 sw=4 sts=4 tw=100 noet: */
?>
